package com.group3.controller.studentController;

import com.group3.domain.Student;
import com.group3.domain.StudentInfo;
import com.group3.pojo.Page;
import com.group3.pojo.receive.StudentReceive;
import com.group3.service.StudentInfoService;
import com.group3.utils.Result;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * InfoController
 *
 * @author HY
 * 2021/06/03 15:28
 **/

@Api(tags = "学生接口")
@RestController
@RequestMapping("/student")
@CrossOrigin
public class StudentInfoController {

    @Resource
    private StudentInfoService studentInfoService;

    @GetMapping(value = "/info")
    @ApiOperation(value = "根据学生id查询学生个人信息和小组成员")
    @ApiImplicitParam(name = "studentId", value = "学生id",
            dataType = "String",required = true)
    /**
     * 获取前端数据：学生id
     */

    public Result getInfoStudent(String studentId){//查询学生个人信息和小组成员
        /**
         * 返回个人信息
         */
        Result result = studentInfoService.getInfoStudent(studentId);

        return result;

    };


    @PutMapping(value = "/projectScore")
    @ApiOperation(value = "根据学生id查询学生项目得分")
    @ApiImplicitParam(name = "studentId", value = "学生id",
            dataType = "String",required = true)
    public Result getProject(String studentId){//查询学生项目得分
        Result result = studentInfoService.getProject(studentId);
        return result;
    }

    @PutMapping(value = "/info/updateEmail")
    @ApiOperation(value = "学生更改自己的邮箱信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentId", value = "学生id",
                    dataType = "String",required = true),
            @ApiImplicitParam(name = "email", value = "学生邮箱",
                    dataType = "String",required = true)})
    public Result updateEmail(String studentId,String email){

        Result result =studentInfoService.updateEmail(studentId,email);

        return result;
    }

    @PostMapping(value = "/info/updatePhone")
    @ApiOperation(value = "学生更改自己的手机号")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentId", value = "学生id",
                    dataType = "String",required = true),
            @ApiImplicitParam(name = "tel", value = "学生手机号",
                    dataType = "String",required = true)})
    public Result updatePhone(String studentId,String tel){

        Result result =studentInfoService.updatePhone(studentId,tel);

        return result;
    }

}
